# Contributor: Sean McAvoy <seanmcavoy@gmail.com>
# Contributor: crapStone <crapstone01@gmail.com>
# Maintainer: Sean McAvoy <seanmcavoy@gmail.com>
pkgname=topgrade
pkgver=16.0.1
pkgrel=0
pkgdesc="run upgrades of packages in OS and other package managers"
url="https://github.com/topgrade-rs/topgrade"
arch="all !s390x !riscv64"
license="GPL-3.0-or-later"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	$pkgname-doc
	"
source="topgrade-$pkgver.tar.gz::https://github.com/topgrade-rs/topgrade/archive/refs/tags/v$pkgver.tar.gz"


prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen

	target/release/topgrade --gen-completion bash > topgrade.bash
	target/release/topgrade --gen-completion fish > topgrade.fish
	target/release/topgrade --gen-completion zsh > _topgrade

	target/release/topgrade --gen-manpage > topgrade.8
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/topgrade "$pkgdir"/usr/bin/topgrade
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/topgrade/LICENSE

	install -Dm644 topgrade.bash "$pkgdir"/usr/share/bash-completion/completions/topgrade
	install -Dm644 topgrade.fish "$pkgdir"/usr/share/fish/vendor_completions.d/topgrade.fish
	install -Dm644 _topgrade "$pkgdir"/usr/share/zsh/site-functions/_topgrade

	install -Dm644 config.example.toml "$pkgdir"/usr/share/doc/topgrade/config.example.toml
	install -Dm644 topgrade.8 "$pkgdir"/usr/share/man/man8/topgrade.8
}

sha512sums="
64cf7c170d7650c76d3a5cc3f92f35bc38367faec89f4eb9b22c24040d98f19fe295671633dbd00d51418c29ac492bc934fe664ad5bc8bbb01a67c5a4d5824be  topgrade-16.0.1.tar.gz
"
